module.exports = {
  /**
   * 海报购买记录
   * @url user/kh/postOrderConfig 前端调用的url参数地址
   */
  main: async (event) => {
    let {
      data = {}, userInfo, util, originalParam
    } = event;
    let {
      uniID,
      pubFun,
      vk,
      db,
      _
    } = util;
    let res = {
      code: 0,
      msg: 'ok'
    };
    let dbName = "vk-cate"

    let {
      _id
    } = data
    if (_id) {
      let couponInfo = await vk.baseDao.findById({
        dbName,
        id: _id
      }, event.util);
      if (!couponInfo) {
        return {
          code: 412,
          msg: '查无此数据'
        }
      }
      data.update_time = vk.pubfn.timeFormat(new Date(),"yyyy-MM-dd hh:mm:ss");
      res.data = await vk.baseDao.update({
        dbName,
        whereJson: {
          _id
        },
        dataJson: data
      }, event.util);
      return res
    } else {
      res.data = await vk.baseDao.add({
        dbName,
        dataJson: data
      }, event.util);
      return res;
    }
  }

}